﻿namespace NTLib.Core.Log.Consumer
{
    using Configuration.Attributes;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

#if DEBUG

    /// <summary>
    /// Define a default consumer for NTLog that normaly MUST be register to NTLog automaticaly througth Configuration mechanisme.
    /// This class exist only in debug mode.
    /// </summary>
    /// <seealso cref="NTLib.Core.Log.ILogConsumer" />
    [TypeExportConfiguration(typeof(ILogConsumer))]
    public class DebugConsoleConsumer : ILogConsumer
    {
        #region Properties

        /// <summary>
        /// Gets types of data the NTlog must filter for this consumer. If null no filter will be apply.
        /// </summary>
        /// <value>
        /// Collection of types used to filter. Following this collection, only log data in type or child of one type present will be send to the consumer.
        /// </value>
        public IReadOnlyCollection<Type> FilterTypes
        {
            get { return null; }
        }

        /// <summary>
        /// Gets types of context the NTlog must filter for this consumer. If null no filter will be apply.
        /// </summary>
        /// <value>
        /// Collection of types used to filter. Following this collection, only log data in type or child of one type present will be send to the consumer.
        /// </value>
        public IReadOnlyCollection<Type> FilterContextTypes
        {
            get { return null; }
        }

        #endregion

        #region Methods

        /// <summary>
        /// Manager the specified log.
        /// </summary>
        /// <param name="log">The log.</param>
        public virtual void Log(LogContainer log)
        {
            Debug.WriteLine(log);
        }

        /// <summary>
        /// Flushes this instance.
        /// </summary>
        /// <returns></returns>
        public async Task FlushAsync()
        {
            await Task.Yield();
        }

        #endregion
    }

#endif

}
